public class test {
    public static  int MaxSubSumOfSequence(int[] array){
        int maxSum = Integer.MIN_VALUE;
        int currentSum = 0;
        if(array == null || array.length==0){
            return Integer.MIN_VALUE;
        }
        for (int i = 0; i < array.length; i++) {
            if (currentSum < 0) {
                currentSum = array[i];
            }else {
                currentSum += array[i];
            }
            maxSum = Math.max(maxSum, currentSum);
        }
        return maxSum;
    }

    public static void main(String[] args){
        int array[]= {1,4,5,-2,-3};
        int max= MaxSubSumOfSequence(array);
        System.out.println(max);
    }
}
